<?php
$vars['helper']->setContainerClass('');
//$vars['helper']->setContainerClass('rounded-box padded');
$vars['helper']->insertMessage();

$user = $vars['user'];
$keys = $vars['keys'];
$links = $vars['links'];
$emailLink = $vars['emailLink'];
$userHelper = $vars['userHelper'];
$rows = $vars['rows'];
$cols = $vars['cols'];
$size = $vars['size'];
$linkWithPlaceholder = $vars['linkWithPlaceholder'];
$userId = $vars['userId'];
$vars['helper']->setTitle(__('Avatar change'));

$referrerField = $vars['referrerField'];

$vars['helper']->addCssFile('profile_avatar_change.css');
?>

<div id="link-back">
<a class="button" 
	href="<?php echo $vars['helper']->createHref('Home')?>">
		<?php echo __('Home'); ?>
</a>
<a class="button" 
	href="<?php $vars['helper']->insertHrefWithNonce('displayProfile', 'Profile', 'display', array('userId'=>$userId )); ?>">
		<?php echo __('Profile'); ?>
</a>
&nbsp;
<h4> <?php echo __('Avatar change'); ?></h4>
</div>

<table id="main_table">
	<tr class="main_row">
		<td>
			<table id="top_choice">
				<tr>
					<td><!-- Current avatar -->
						<div id="current_avatar" class="choice_label">
							<?php echo __('Keep the current avatar');?>
						</div>
						<div class="avatar_link">
			    			<?php echo $userHelper->insertAvatar($size, $vars['helper']->createHrefWithNonce('displayProfile', 'Profile', 'display', array('userId' => $userId))); ?>
						</div>
					</td>
					<td><!-- email avatar, 'default' -->
						<div id="email_avatar" class="choice_label">
							<?php echo __('Generated by email');?>
						</div>
						<div class="avatar_link">
							<a rel="nofollow"
				    			class="avatar"
				    			href="<?php echo strtr($linkWithPlaceholder, array('%avatarKey%' => $user->getEmail())); ?>">
								<img src="<?php echo $emailLink; ?>"
									alt="Avatar Image" class="avatar"
									width="<?php echo $size; ?>"
									height="<?php echo $size; ?>">
							</a>
						</div>
			    	</td>
			    </tr>
			</table>
		</td>
	</tr>
	
	<tr class="main_row">
		<td>
			<form
				method="post"
				enctype="multipart/form-data"
				action="<?php $vars['helper']->insertHrefWithNonce('displayCropAvatar', 'Profile', 'displayCropImage', array('userId' => $userId)); ?>">
					
					<p style="width: 520px"><?php echo __( 'Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Image\' to proceed.' ) ?></p>
				
					<p id="avatar-upload">
						<input type="file" name="avatar_file" id="file" />
						<input type="submit" name="upload" id="upload" value="<?php echo __( 'Upload Image' ) ?>" />
					</p>
					<?php echo $referrerField; ?>
			</form>
		</td>
	</tr>
	
	<tr class="main_row">
		<td>
			<div>
				<?php echo __('You can also choose an avatar from this set, just click on the avatar you want');?>
			</div>
			<div><a href="<?php $vars['helper']->insertHrefWithNonce('displayEditAvatarForm', 'Profile', 'displayEditAvatarForm', array('userId' => $userId)); ?>"><?php echo __('Reload'); ?></a></div>
			<table id="image_row">
				<?php for($r = 0; $r < $rows ; $r++): ?>
					<tr>
					<?php for($c = 0; $c < $cols ; $c++): ?>
				  		<td><!-- one random avatar proposed -->
			    			<a rel="nofollow"
			    				class="avatar"
			    				href="<?php echo strtr($linkWithPlaceholder, array('%avatarKey%' => $keys[$r * $cols + $c])); ?>">
								<img src="<?php echo $links[$r * $cols + $c]; ?>"
									alt="Avatar Image" class="avatar"
									width="<?php echo $size; ?>"
									height="<?php echo $size; ?>">
							</a>
						</td>
					<?php endfor; ?>
					</tr>
				<?php endfor; ?>
			</table>
		</td>
	</tr>
	<tr class="main_row">
		<td>
			<?php echo __('You can also used an online avatar maker: '); ?>
			<ul id="avatar-site-list">
				<li>
					<a href="http://toonlet.com/char" title="toonlet">toonlet</a>
				</li>
				<li>
					<a href="http://www.doppelme.com/create/" title="DoppelMe">DoppelMe</a>
				</li>
				<li>
					<a href="http://www.weeworld.com/" title="WeeWorld">WeeWorld</a>
				</li>
			</ul>
		</td>
	</tr>
</table>

